package qx.hyj.petrescue.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import qx.hyj.petrescue.entity.Friend;
import qx.hyj.petrescue.entity.Users;

import java.util.List;

@Mapper
public interface FriendMapper extends BaseMapper<Friend> {

    @Select("SELECT f.* "+
            "FROM friend f LEFT JOIN users u ON f.friendId = u.id "+
            "WHERE f.userId = #{userId} and f.isOK = 1 or f.friendId = #{userId} and f.isOK = 1")
    List<Friend> selectFriendByUserId(Integer userId);

    @Select("SELECT u.* "+
            "FROM friend f LEFT JOIN users u ON f.userId = u.id "+
            "WHERE f.friendId = #{userId} and f.isOK = 0")
    List<Users> selectNewFriendByUserId(Integer userId);
}
